package main
import (
	"reflect"
	"sync"
	"time"
	"fmt"
//	"time"
)
func write(ch chan int){
	for i:=0;i<5;i++{
		ch <-i
		fmt.Println("successfully wrote",i,"to ch")
	}
	close(ch)
}

func process(i int,wg *sync.WaitGroup){
	fmt.Println("started Goroutine",i)
	time.Sleep(2*time.Second)
	fmt.Printf("Gorouteine %d ended\n",i)
	wg.Done()
}
func server1(ch chan string){
	time.Sleep(6 *time.Second)
	ch<-"from servel1"
}
func server2(ch chan string){
	time.Sleep(6 *time.Second)
	ch<-"from servel2"
}
type order struct{
	ordId int
	customerId int
}
func createQuery(o order)string{
	i :=fmt.Sprintf("insert into order values(%d,%d)",o.ordId,o.customerId)
	return i
}
func createQuery1(q interface{}){
	t :=reflect.TypeOf(q)
	v :=reflect.ValueOf(q)
	fmt.Println("type ",t)
	fmt.Println("value",v)
}
func main(){
	o :=order{
		ordId:1234,
		customerId:345,
	}
//fmt.Println(createQuery1(o))
	createQuery1(o)
}
	/*
a:=5
func(){
	fmt.Println("a=",a)
}()
}
	/*
	output1 :=make(chan string)
	output2 :=make(chan string)
	go server1(output1)
	go server2(output2)
	select {
	case s1 :=<-output1:
		fmt.Println(s1)
	case s2 :=<-output2:
		fmt.Println(s2)
	}
}
	/*
	no :=3
	var wg sync.WaitGroup
	for i :=0;i<no;i++{
		wg.Add(1)
		go process(i,&wg)
	}
	wg.Wait()
	fmt.Println("All go routine finished executing")
}
	/*
	ch :=make(chan  string,3)
	ch <-"naveen"
	ch <-"paul"
	fmt.Println(cap(ch),len(ch),<-ch,len(ch))
}
	/*

	ch :=make(chan string,2)
	ch <-"naveen"
	ch <-"paul"
//	ch <-"steve"
	fmt.Println(<-ch)
	fmt.Println(<-ch)
}
*/
	/*
	ch :=make(chan int,3)
	go write(ch)
	time.Sleep(2*time.Second)
	for v:=range ch{
		fmt.Println("read value",v,"from ch")
		time.Sleep(2*time.Second)
		}
	}
	*/
